{{- if .Values.prometheus.longtermRetentionDays }}
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: prometheus-longterm-federation-availability
  namespace: d8-monitoring
  {{- include "helm_lib_module_labels" (list . (dict "prometheus" "main")) | nindent 2 }}
spec:
  jobLabel: prometheus-longterm-federation-availability
  podMetricsEndpoints:
  - port: https
    scheme: https
    bearerTokenSecret:
      name: "prometheus-token"
      key: "token"
    tlsConfig:
      insecureSkipVerify: true
    path: "/federate"
    relabelings:
    - regex: endpoint|namespace
      action: labeldrop
    - sourceLabels: [__meta_kubernetes_pod_ready]
      regex: "true"
      action: keep
    metricRelabelings:
    - sourceLabels: [__name__]
      regex:  'up'
      targetLabel: __name__
      replacement: 'longterm_federate_scrape_successful'
    params:
      'match[]':
      - '{__name__="up", job="federate"}'
  selector:
    matchLabels:
      app.kubernetes.io/name: prometheus
      prometheus: longterm
  namespaceSelector:
    matchNames:
    - d8-monitoring
{{- end }}
